
'===============================================================================
'  Generated From - VbNet_dOOdads_BusinessEntity.vbgen
' 
'  ** IMPORTANT  ** 
'  How to Generate your stored procedures:
' 
'  SQL      = SQL_StoredProcs.vbgen
'  ACCESS   = Access_StoredProcs.vbgen
'  ORACLE   = Oracle_StoredProcs.vbgen
'  FIREBIRD = FirebirdStoredProcs.vbgen
'
'  The supporting base class OracleClientEntity is in the Architecture directory in "dOOdads".
'  
'  This object is 'MustInherit' which means you need to inherit from it to be able
'  to instantiate it.  This is very easilly done. You can Override properties and
'  methods in your derived class, this allows you to regenerate this class at any
'  time and not worry about overwriting custom code. 
'
'  NEVER EDIT THIS FILE.
'
'  Public Class YourObject
'    Inherits _YourObject
'
'  End Class
'
'===============================================================================

' Generated by MyGeneration Version # (1.0.0.4)

Imports System
Imports System.Data
Imports System.Data.OracleClient
Imports System.Collections
Imports System.Collections.Specialized

Imports MyGeneration.dOOdads

Namespace ORACLE

    Public MustInherit Class _MYEMPLOYEES
        Inherits OracleClientEntity

        Public Sub New()
            Me.SchemaGlobal = "HR."
            Me.QuerySource = "MYEMPLOYEES"
            Me.MappingName = "MYEMPLOYEES"
        End Sub

        '=================================================================
        '  Public Overrides Sub AddNew()
        '=================================================================
        '
        '=================================================================
        Public Overrides Sub AddNew()
            MyBase.AddNew()

        End Sub

        Public Overrides Sub FlushData()
            Me._whereClause = Nothing
            MyBase.FlushData()
        End Sub


        '=================================================================
        '  	Public Function LoadAll() As Boolean
        '=================================================================
        '  Loads all of the records in the database, and sets the currentRow to the first row
        '=================================================================
        Public Function LoadAll() As Boolean

            Dim parameters As ListDictionary = Nothing

            parameters = New ListDictionary
            Dim p As OracleParameter = New OracleParameter("outCursor", OracleType.Cursor)
            p.Direction = ParameterDirection.Output
            parameters.Add(p, Nothing)


            Return MyBase.LoadFromSql(Me.SchemaStoredProcedure + "PL_MYEMPLOYEES", parameters)

        End Function

        '=================================================================
        ' Public Overridable Function LoadByPrimaryKey()  As Boolean
        '=================================================================
        '  Loads a single row of via the primary key
        '=================================================================
        Public Overridable Function LoadByPrimaryKey(ByVal EMPLOYEE_ID As Decimal) As Boolean

            Dim parameters As ListDictionary = New ListDictionary
            parameters.Add(Me.Parameters.EMPLOYEE_ID, EMPLOYEE_ID)


            Dim p As OracleParameter = New OracleParameter("outCursor", OracleType.Cursor)
            p.Direction = ParameterDirection.Output
            parameters.Add(p, Nothing)

            Return MyBase.LoadFromSql(Me.SchemaStoredProcedure + "PK_MYEMPLOYEES", parameters)

        End Function

#Region "Parameters"
        Protected Class Parameters

            Public Shared ReadOnly Property EMPLOYEE_ID() As OracleParameter
                Get
                    Return New OracleParameter("p_EMPLOYEE_ID", OracleType.Number, 0)
                End Get
            End Property

            Public Shared ReadOnly Property FIRST_NAME() As OracleParameter
                Get
                    Return New OracleParameter("p_FIRST_NAME", OracleType.VarChar, 80)
                End Get
            End Property

            Public Shared ReadOnly Property LAST_NAME() As OracleParameter
                Get
                    Return New OracleParameter("p_LAST_NAME", OracleType.VarChar, 80)
                End Get
            End Property

        End Class
#End Region

#Region "ColumnNames"
        Public Class ColumnNames

            Public Const EMPLOYEE_ID As String = "EMPLOYEE_ID"
            Public Const FIRST_NAME As String = "FIRST_NAME"
            Public Const LAST_NAME As String = "LAST_NAME"

            Public Shared Function ToPropertyName(ByVal columnName As String) As String

                If ht Is Nothing Then

                    ht = New Hashtable

                    ht(EMPLOYEE_ID) = _MYEMPLOYEES.PropertyNames.EMPLOYEE_ID
                    ht(FIRST_NAME) = _MYEMPLOYEES.PropertyNames.FIRST_NAME
                    ht(LAST_NAME) = _MYEMPLOYEES.PropertyNames.LAST_NAME

                End If

                Return CType(ht(columnName), String)

            End Function

            Private Shared ht As Hashtable = Nothing
        End Class
#End Region

#Region "PropertyNames"
        Public Class PropertyNames

            Public Const EMPLOYEE_ID As String = "EMPLOYEE_ID"
            Public Const FIRST_NAME As String = "FIRST_NAME"
            Public Const LAST_NAME As String = "LAST_NAME"

            Public Shared Function ToColumnName(ByVal propertyName As String) As String

                If ht Is Nothing Then

                    ht = New Hashtable

                    ht(EMPLOYEE_ID) = _MYEMPLOYEES.ColumnNames.EMPLOYEE_ID
                    ht(FIRST_NAME) = _MYEMPLOYEES.ColumnNames.FIRST_NAME
                    ht(LAST_NAME) = _MYEMPLOYEES.ColumnNames.LAST_NAME

                End If

                Return CType(ht(propertyName), String)

            End Function

            Private Shared ht As Hashtable = Nothing

        End Class
#End Region

#Region "StringPropertyNames"
        Public Class StringPropertyNames

            Public Const EMPLOYEE_ID As String = "s_EMPLOYEE_ID"
            Public Const FIRST_NAME As String = "s_FIRST_NAME"
            Public Const LAST_NAME As String = "s_LAST_NAME"

        End Class
#End Region

#Region "Properties"
        Public Overridable Property EMPLOYEE_ID() As Decimal
            Get
                Return MyBase.GetDecimal(ColumnNames.EMPLOYEE_ID)
            End Get
            Set(ByVal Value As Decimal)
                MyBase.SetDecimal(ColumnNames.EMPLOYEE_ID, Value)
            End Set
        End Property

        Public Overridable Property FIRST_NAME() As String
            Get
                Return MyBase.GetString(ColumnNames.FIRST_NAME)
            End Get
            Set(ByVal Value As String)
                MyBase.SetString(ColumnNames.FIRST_NAME, Value)
            End Set
        End Property

        Public Overridable Property LAST_NAME() As String
            Get
                Return MyBase.GetString(ColumnNames.LAST_NAME)
            End Get
            Set(ByVal Value As String)
                MyBase.SetString(ColumnNames.LAST_NAME, Value)
            End Set
        End Property


#End Region

#Region "String Properties"

        Public Overridable Property s_EMPLOYEE_ID() As String
            Get
                If Me.IsColumnNull(ColumnNames.EMPLOYEE_ID) Then
                    Return String.Empty
                Else
                    Return MyBase.GetDecimalAsString(ColumnNames.EMPLOYEE_ID)
                End If
            End Get
            Set(ByVal Value As String)
                If String.Empty = Value Then
                    Me.SetColumnNull(ColumnNames.EMPLOYEE_ID)
                Else
                    Me.EMPLOYEE_ID = MyBase.SetDecimalAsString(ColumnNames.EMPLOYEE_ID, Value)
                End If
            End Set
        End Property

        Public Overridable Property s_FIRST_NAME() As String
            Get
                If Me.IsColumnNull(ColumnNames.FIRST_NAME) Then
                    Return String.Empty
                Else
                    Return MyBase.GetStringAsString(ColumnNames.FIRST_NAME)
                End If
            End Get
            Set(ByVal Value As String)
                If String.Empty = Value Then
                    Me.SetColumnNull(ColumnNames.FIRST_NAME)
                Else
                    Me.FIRST_NAME = MyBase.SetStringAsString(ColumnNames.FIRST_NAME, Value)
                End If
            End Set
        End Property

        Public Overridable Property s_LAST_NAME() As String
            Get
                If Me.IsColumnNull(ColumnNames.LAST_NAME) Then
                    Return String.Empty
                Else
                    Return MyBase.GetStringAsString(ColumnNames.LAST_NAME)
                End If
            End Get
            Set(ByVal Value As String)
                If String.Empty = Value Then
                    Me.SetColumnNull(ColumnNames.LAST_NAME)
                Else
                    Me.LAST_NAME = MyBase.SetStringAsString(ColumnNames.LAST_NAME, Value)
                End If
            End Set
        End Property


#End Region

#Region "Where Clause"
        Public Class WhereClause

            Public Sub New(ByVal entity As BusinessEntity)
                Me._entity = entity
            End Sub

            Public ReadOnly Property TearOff() As TearOffWhereParameter
                Get
                    If _tearOff Is Nothing Then
                        _tearOff = New TearOffWhereParameter(Me)
                    End If

                    Return _tearOff
                End Get
            End Property

#Region "TearOff's"
            Public Class TearOffWhereParameter

                Public Sub New(ByVal clause As WhereClause)
                    Me._clause = clause
                End Sub


                Public ReadOnly Property EMPLOYEE_ID() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.EMPLOYEE_ID, Parameters.EMPLOYEE_ID)
                        Me._clause._entity.Query.AddWhereParemeter(where)
                        Return where
                    End Get
                End Property

                Public ReadOnly Property FIRST_NAME() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.FIRST_NAME, Parameters.FIRST_NAME)
                        Me._clause._entity.Query.AddWhereParemeter(where)
                        Return where
                    End Get
                End Property

                Public ReadOnly Property LAST_NAME() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.LAST_NAME, Parameters.LAST_NAME)
                        Me._clause._entity.Query.AddWhereParemeter(where)
                        Return where
                    End Get
                End Property


                Private _clause As WhereClause
            End Class
#End Region

            Public ReadOnly Property EMPLOYEE_ID() As WhereParameter
                Get
                    If _EMPLOYEE_ID_W Is Nothing Then
                        _EMPLOYEE_ID_W = TearOff.EMPLOYEE_ID
                    End If
                    Return _EMPLOYEE_ID_W
                End Get
            End Property

            Public ReadOnly Property FIRST_NAME() As WhereParameter
                Get
                    If _FIRST_NAME_W Is Nothing Then
                        _FIRST_NAME_W = TearOff.FIRST_NAME
                    End If
                    Return _FIRST_NAME_W
                End Get
            End Property

            Public ReadOnly Property LAST_NAME() As WhereParameter
                Get
                    If _LAST_NAME_W Is Nothing Then
                        _LAST_NAME_W = TearOff.LAST_NAME
                    End If
                    Return _LAST_NAME_W
                End Get
            End Property

            Private _EMPLOYEE_ID_W As WhereParameter = Nothing
            Private _FIRST_NAME_W As WhereParameter = Nothing
            Private _LAST_NAME_W As WhereParameter = Nothing

            Public Sub WhereClauseReset()

                _EMPLOYEE_ID_W = Nothing
                _FIRST_NAME_W = Nothing
                _LAST_NAME_W = Nothing
                Me._entity.Query.FlushWhereParameters()

            End Sub

            Private _entity As BusinessEntity
            Private _tearOff As TearOffWhereParameter
        End Class

        Public ReadOnly Property Where() As WhereClause
            Get
                If _whereClause Is Nothing Then
                    _whereClause = New WhereClause(Me)
                End If

                Return _whereClause
            End Get
        End Property

        Private _whereClause As WhereClause = Nothing
#End Region

        Protected Overrides Function GetInsertCommand() As IDbCommand

            Dim cmd As OracleCommand = New OracleCommand
            cmd.CommandType = CommandType.StoredProcedure
            cmd.CommandText = Me.SchemaStoredProcedure + "PI_MYEMPLOYEES"

            CreateParameters(cmd)

            Dim p As OracleParameter
            p = cmd.Parameters(Parameters.EMPLOYEE_ID.ParameterName)
            p.Direction = ParameterDirection.Output

            Return cmd

        End Function

        Protected Overrides Function GetUpdateCommand() As IDbCommand

            Dim cmd As OracleCommand = New OracleCommand
            cmd.CommandType = CommandType.StoredProcedure
            cmd.CommandText = Me.SchemaStoredProcedure + "PU_MYEMPLOYEES"

            CreateParameters(cmd)

            Return cmd

        End Function

        Protected Overrides Function GetDeleteCommand() As IDbCommand

            Dim cmd As OracleCommand = New OracleCommand
            cmd.CommandType = CommandType.StoredProcedure
            cmd.CommandText = Me.SchemaStoredProcedure + "PD_MYEMPLOYEES"

            Dim p As OracleParameter
            p = cmd.Parameters.Add(Parameters.EMPLOYEE_ID)
            p.SourceColumn = ColumnNames.EMPLOYEE_ID
            p.SourceVersion = DataRowVersion.Current


            Return cmd

        End Function

        Private Sub CreateParameters(ByVal cmd As OracleCommand)

            Dim p As OracleParameter
            p = cmd.Parameters.Add(Parameters.EMPLOYEE_ID)
            p.SourceColumn = ColumnNames.EMPLOYEE_ID
            p.SourceVersion = DataRowVersion.Current

            p = cmd.Parameters.Add(Parameters.FIRST_NAME)
            p.SourceColumn = ColumnNames.FIRST_NAME
            p.SourceVersion = DataRowVersion.Current

            p = cmd.Parameters.Add(Parameters.LAST_NAME)
            p.SourceColumn = ColumnNames.LAST_NAME
            p.SourceVersion = DataRowVersion.Current


        End Sub

    End Class

End Namespace
